package zfc.D0911;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class P2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine().trim());

        Map<Integer, Integer> map = new HashMap<>();
        // 内存块[大小 数量]
        int[][] blocks = new int[N][2];
        for (int i = 0; i < N; i++) {
            blocks[i] = Arrays.stream(scanner.nextLine().trim().split("\\s+")).mapToInt(Integer::parseInt).toArray();
            for (int j = 0; j < blocks[i][1]; j++) {
                map.put(map.size(), blocks[i][0]);
            }
        }
        int M = Integer.parseInt(scanner.nextLine().trim());
        // 需要分配的内存
        int[] allocs = Arrays.stream(scanner.nextLine().trim().split("\\s+")).mapToInt(Integer::parseInt).toArray();

    }

    private static int solve(int[][] blocks, int[] allocs) {
        //排序
        Arrays.sort(blocks, (a, b) -> {
            return a[0] - b[0];
        });
        Arrays.sort(allocs);
        return 0;
    }


}
